﻿using CoreEx.Common.Data;
using LinFu.IoC.Configuration;

namespace CoreEx.Common.Implementation.Data
{
    /// <summary>
    /// Represents a cell value in an <see cref="ITable"/> instance.
    /// </summary>
    [Implements(typeof(ICell), LifecycleType.OncePerRequest)]
    public class Cell : ICell
    {
        /// <summary>
        /// Gets or sets the <see cref="IRow"/> that this <see cref="ICell"/> belongs to.
        /// </summary>
        public IRow Row { get; set;}


        /// <summary>
        /// Gets or sets the <see cref="IColumn"/> that this <see cref="ICell"/> is associated with.
        /// </summary>
        public IColumn Column { get; set;}


        /// <summary>
        /// Gets or sets the <see cref="ICell"/> value.
        /// </summary>
        public object Value { get; set;}
        
        /// <summary>
        /// Returns the value of the <see cref="ICell"/>
        /// </summary>
        /// <returns><see cref="string"/></returns>
        public override string ToString()
        {
            if (Value == null)
                return "NULL";

            return Value.ToString();
        }
    }
}